home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Commun⁄Network / Telnet 2.5.src.ThinkC / source / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-26  |  17.2 KB  |  693 lines  |  [TEXT/MPS ]

  1. #ifndef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    config.c
  6. *    User interface code for NCSA Telnet for the Macintosh
  7. *     by Gaige B. Paulsen
  8. ****************************************************************************
  9. *                                                                          *
  10. *      Uses    :                                                               *
  11. *      TCP/IP kernel for NCSA Telnet                                       *
  12. *      by Tim Krauskopf                                                    *
  13. *       with Macintosh code by Gaige B. Paulsen                                 *
  14. *                                                                          *
  15. *      National Center for Supercomputing Applications                     *
  16. *      152 Computing Applications Building                                 *
  17. *      605 E. Springfield Ave.                                             *
  18. *      Champaign, IL  61820                                                *
  19. *                                                                          *
  20. *                                                                          *
  21. ****************************************************************************
  22. *
  23. *    Configuration structure and Set file functions.    
  24. *
  25. *    Called by:
  26. *        menu.c
  27. *        maclook.c
  28. */
  29.  
  30. #include <stdio.h>
  31. #include <ctype.h>
  32. #include <string.h>
  33.  
  34. #include <Dialogs.h>
  35. #include <Files.h>
  36. #include    <Fonts.h>
  37. #include <Memory.h>
  38. #include    <QuickDraw.h>
  39. #include    <SegLoad.h>
  40. /*#include <Strings.h>        /* BYU LSC */
  41. #include "prefs.h"            /* BYU LSC */
  42. #include    "configrec.h"
  43. #include "confile.h"
  44. #include "event.h"
  45. #include     "hostform.h" 
  46. #include "maclook.h"
  47. #include "menu.h"
  48. #include "netevent.h"
  49.  
  50. #ifdef MPW
  51. #include "mpw.h"
  52. #endif
  53.  
  54. extern int numwindows, whichMenus;
  55.  
  56. char *Cspace;
  57.  
  58. char *Ckeyw[] = {
  59.         "",                /* Skip so we start at one */
  60.         "name",            /* Name of session                **  1 **/
  61.         "host",            /* Name of host to use            **  2 **/
  62.         "size",            /* Window size (user)            **  3 **/
  63.         "scrollback",    /* Amount of scrollback            **  4 **/
  64.         "backspace",    /* set to backspace                **  5 **/
  65.         "delete",        /* set to delete                **  6 **/
  66.         "key0",            /* Macro definition key 0        **  7 **/
  67.         "key1",            /* Macro definition key 1        **  8 **/
  68.         "key2",            /* Macro definition key 2        **  9 **/
  69.         "key3",            /* Macro definition key 3        ** 10 **/
  70.         "key4",            /* Macro definition key 4        ** 11 **/
  71.         "key5",            /* Macro definition key 5        ** 12 **/
  72.         "key6",            /* Macro definition key 6        ** 13 **/
  73.         "key7",            /* Macro definition key 7        ** 14 **/
  74.         "key8",            /* Macro definition key 8        ** 15 **/
  75.         "key9",            /* Macro definition key 9        ** 16 **/
  76.         "commandkeys",    /* Command keys active?            ** 17 **/
  77.         "erase",        /* Erase mode (as in bs/del )      ** 18 **/
  78.         "width",        /* Width of the current session ** 19 **/
  79.         "tekclear",        /* Clear Tek for each drawing   ** 20 **/
  80.         "vtwidth",        /* Tim, I am going to hit you   ** 21 **/
  81.         "rgb0",            /* RGB Color #0                    ** 22 **/
  82.         "rgb1",            /* RGB Color #1                    ** 23 **/
  83.         "rgb2",            /* RGB Color #2                    ** 24 **/
  84.         "rgb3",            /* RGB Color #3                    ** 25 **/
  85.         "font",            /* Font for your window            ** 26 **/
  86.         "fsize",        /* Size for mr. font            ** 27 **/
  87.         "nlines",        /* number of active lines       ** 28 **/
  88.         "keystop",        /*  XOFF key                    ** 29 **/
  89.         "keygo",        /*  XON key                     ** 30 **/
  90.         "keyip",        /* interrupt process key        ** 31 **/
  91.         "crmap",        /* the CR mapping                ** 32 **/
  92.         "linemode",        /* allow line mode                ** 33 **/    /* BYU 2.4.9 */
  93.         "eightbit",        /* allow 8 bit font                ** 34 **/    /* BYU 2.4.9 */
  94.         "ftp",            /* ftp session                    ** 35 **/    /* BYU */
  95.         "serial",        /* serial port connection        ** 36 **/    /* BYU serial */
  96.         "port",            /* port number                     ** 37 **/    /* NCSA */
  97.         ""                /* END OF LIST */
  98.         };
  99. char *AffWords[]= {
  100.         "yes",
  101.         "y",
  102.         "on",
  103.         "active",
  104.         "true",
  105.         "alive",
  106.         "yup",
  107.         "yep",
  108.         "yessir",
  109.         "affirmative",
  110.         "ja",
  111.         ""
  112.         };
  113.  
  114. int CONFstate=0,CONFactive=0;
  115. int position, inquote, lineno ;   /* state vars */    
  116. FILE *fp;
  117.  
  118. ConfigRec config;
  119.  
  120. int affirmative( s)
  121. char *s;
  122. {
  123.     int i;
  124.  
  125.     for (i=0; i<position; i++)
  126.         s[i] = tolower( s[i] );
  127.  
  128.     for (i=0;  *AffWords[i] && strcmp(AffWords[i],s); i++) ;
  129.     if (*AffWords[i])
  130.         return(1);
  131.     else
  132.         return(0);
  133. }
  134.  
  135. /* Prime the Configuration with Default Data (Capital D) */
  136. void configdefault
  137.   (
  138.     ConfigRec *config
  139.   )
  140. {
  141.     config->tektype =0;
  142.     config->bsdel=1;                        /* Default to Delete */
  143.     config->ftpwind =0;                        /* not an ftp window */
  144.     config->width=80;                        /*     "    "  "     "    */
  145.     config->nlines=24;
  146.     config->tekclear=0;
  147.     config->clearsave=0;
  148.     config->connectionType = 0;                /* BYU serial - not a serial port connection */
  149.     config->ftpstate = 0;                    /* BYU - not at ftp session */
  150.     config->halfdup=0;
  151.     config->crmap=0x0a;
  152.     config->vtwrap=0;
  153.     config->scrollback=120;                    /* Should be user defined */
  154.     config->machine="newton";                /* and host name pointer */
  155.     config->name="newton";                    /* and real name pointer */
  156.     config->port = 23;                        /* default is to use telnet port */
  157.     config->window.top   = config->stdwindow.top   = 40 +( numwindows *(5+Prefs.stag*15));
  158.     config->window.left  = config->stdwindow.left  = 5 +( numwindows *(5+Prefs.stag*15));
  159.     config->window.bottom= config->stdwindow.bottom=30000 +( numwindows *(5+Prefs.stag*15));
  160.     config->window.right = config->stdwindow.right =30000 +( numwindows *(5+Prefs.stag*15));
  161.     config->red[0]        =     0;
  162.     config->green[0]    =     0;
  163.     config->blue[0]        =     0;
  164.     config->red[1]        = 65535;
  165.     config->green[1]    = 65535;
  166.     config->blue[1]        = 65535;
  167.     config->red[2]        =     0;
  168.     config->green[2]    = 61183;
  169.     config->blue[2]        = 11060;
  170.     config->red[3]        = 61183;
  171.     config->green[3]    =  2079;
  172.     config->blue[3]        =  4938;
  173.     config->font        =     4;
  174.     config->fsize        =      9;
  175.     config->TELstop        =    19;
  176.     config->TELgo        =    17;
  177.     config->TELip        =     3;
  178.     config->lineAllow    =     1;
  179.     config->eightbit    =     1;    /* BYU 2.4.9 */
  180. }
  181.  
  182. /* Prime the Configuration with real data.... */
  183. void primeConfig
  184.   (
  185.     ConfigRec *config
  186.   )
  187. {
  188.     struct machinfo *mp;
  189.     char s[255];
  190.  
  191.     mp = Shostlook( config->machine);
  192.     if (mp==NULL)
  193.         mp = Shostlook("default");
  194.     if (mp!= NULL) {
  195.         config->bsdel = mp->bksp == 127;
  196.         config->width = mp->vtwidth;
  197.         config->tektype = mp->tektype;
  198.         config->nlines = mp->nlines;
  199.         config->tekclear=1;
  200.         config->clearsave = mp->clearsave;
  201.         config->connectionType = 0;            /* BYU serial - not a serial port connection */
  202.         config->ftpstate = 0;                /* BYU - not at ftp session */
  203.         config->lineAllow = mp->linemode;    /* BYU 2.4.9 */
  204.         config->eightbit = mp->eightbit;    /* BYU 2.4.9 */
  205.         config->halfdup = mp->halfdup;
  206.         config->crmap = mp->crmap;
  207.         config->scrollback = mp->bkscroll;
  208.         config->vtwrap = mp->vtwrap;
  209.         config->port = mp->port;
  210.         strcpy( s, (char *) mp->font);        /* BYU LSC */
  211.         c2pstr(s);                            /* BYU LSC */
  212.         GetFNum( s, &config->font);            /* BYU LSC */
  213.         config->red[0]        = mp->nfcolor[0];
  214.         config->green[0]    = mp->nfcolor[1];
  215.         config->blue[0]        = mp->nfcolor[2];
  216.         config->red[1]        = mp->nbcolor[0];
  217.         config->green[1]    = mp->nbcolor[1];
  218.         config->blue[1]        = mp->nbcolor[2];
  219.         config->red[2]        = mp->bfcolor[0];
  220.         config->green[2]    = mp->bfcolor[1];
  221.         config->blue[2]        = mp->bfcolor[2];
  222.         config->red[3]        = mp->bbcolor[0];
  223.         config->green[3]    = mp->bbcolor[1];
  224.         config->blue[3]        = mp->bbcolor[2];
  225.         config->fsize        = mp->fsize;
  226.         config->TELstop        = mp->skey;
  227.         config->TELgo        = mp->qkey;
  228.         config->TELip        = mp->ckey;
  229.         config->window.top   = config->stdwindow.top   = 40 +( numwindows *(5+Prefs.stag*15));
  230.         config->window.left  = config->stdwindow.left  =  5 +( numwindows *(5+Prefs.stag*15));
  231.         config->window.bottom= config->stdwindow.bottom= 30000 +( numwindows *(5+Prefs.stag*15));
  232.         config->window.right = config->stdwindow.right = 30000 +( numwindows *(5+Prefs.stag*15));
  233.         }
  234.     else {
  235.         config->bsdel = 1;
  236.         config->width = 80;
  237.         config->nlines = 24;
  238.         config->tekclear=1;
  239.         config->clearsave=1;
  240.         config->connectionType = 0;            /* BYU serial - not a serial port connection */
  241.         config->ftpstate = 0;                /* BYU - not at ftp session */
  242.         config->halfdup = 0;
  243.         config->crmap = 0x0a;
  244.         config->scrollback = 120;
  245.         config->vtwrap = 0;
  246.         config->tektype = 0;
  247.     }
  248.  
  249.     if (config->width <2)
  250.         if (config->width ==0) 
  251.             config->width=80;
  252.         else config->width=132;
  253.         
  254.     if (config->TELip <= 0)
  255.         config->TELip = -1;        /* disable it */
  256.     if (config->TELstop <= 0)
  257.         config->TELstop = -1;        /* disable it */
  258.     if (config->TELgo <= 0)
  259.         config->TELgo = -1;        /* disable it */
  260. }
  261.  
  262. int confile
  263.   (
  264.     char *s
  265.   )
  266.   {
  267.     int i,scrn;
  268.     unsigned int a,b,c,d;
  269.  
  270.     putln(s);
  271.     if (!(*s) )
  272.         return(0);
  273.  
  274.     switch( CONFstate) {
  275.         case 0:                /* No keyword yet! */
  276.             for (i=0; i<position; i++)
  277.                 s[i] = tolower( s[i] );
  278.  
  279.             for (i=1;  *Ckeyw[i] && strcmp(Ckeyw[i],s); i++) ;
  280.  
  281.             if ( !(*Ckeyw[i]) ) {
  282.                 putln("ERROR IN KEYWORD!");
  283.                 putln(s);
  284.                 return(1);
  285.                 }
  286.  
  287.             CONFstate=i;
  288.  
  289.             if (CONFstate==5) {
  290.                 config.bsdel=0;
  291.                 CONFstate=0;
  292.                 }
  293.             if (CONFstate==6) {
  294.                 config.bsdel=1;
  295.                 CONFstate=0;
  296.                 }
  297.             break;
  298.  
  299.         case 1:                /* NAME */
  300.             putln("NAME");
  301.             { char *p;
  302.             if (NULL == (p = NewPtr(40000))) {        /* BYU LSC */
  303. #ifndef MPW
  304.                 OtherError((char *) "\PLoad Set Error:",(char *) "\PNo space for machine name");    /* BYU LSC */
  305. #else
  306.                 OtherError("Load Set Error:","Not enough memory to open");
  307. #endif MPW
  308.                 return(-1);
  309.                 }
  310.             else
  311.                 DisposPtr(p);
  312.             }
  313.             if (CONFactive) {
  314.                 putln("Open attempt....");
  315.                 scrn=addport( &config );    /* Make our user window */
  316.                 if (scrn<0) {
  317.                     putln("ERROR IN OPENING!! ");
  318.                     return(42);
  319.                     }
  320.                 }
  321.  
  322.             configdefault( &config );                            /* Set up the defaults */
  323.             config.name = NewPtr( strlen( s) +2);                /* BYU LSC - Allocate namespace */
  324.             strcpy(config.name, s);                                /* Move name in */
  325.             config.name= config.name;
  326.             CONFstate=0;
  327.             CONFactive=1;
  328.             break;
  329.  
  330.         case 2:
  331.             putln("HOST");
  332.             config.machine = NewPtr( strlen( s) +2);        /* BYU LSC - Allocate namespace */
  333.             if (config.machine==NULL) {
  334. #ifndef MPW
  335.                 OtherError((char *) "\PLoad Set Error:",(char *) "\PNo space for machine name");    /* BYU LSC */
  336. #else
  337.                 OtherError("Load Set Error:","No space for machine name");
  338. #endif MPW
  339.                 return(-1);
  340.                 }
  341.             strcpy(config.machine, s);                            /* Move name in */
  342.             primeConfig(&config);
  343.             CONFstate=0;
  344.             break;
  345.  
  346.         case 3:                /* SIZE */
  347.             putln("SIZE");
  348.             if ( 4 != sscanf(s, "{%d,%d,%d,%d}", &a, &b, &c,&d) ) {
  349.                 putln("Error in window size");
  350.                 return(2);
  351.                 }
  352.             
  353.             config.window.top=a;
  354.             config.window.left=b;
  355.             config.window.bottom=c;
  356.             config.window.right=d;
  357.             CONFstate=0;
  358.             break;
  359.  
  360.         case 4:
  361.             if ( 1 != sscanf(s,"%d", &a) ) {
  362.                 putln(" You need a parameter after Scrollback ");
  363.                 return(1);
  364.                 }
  365.             config.scrollback=a;
  366.             CONFstate=0;
  367.             break;
  368.  
  369.         case 5:
  370.             config.bsdel=0;
  371.             CONFstate=0;
  372.             break;
  373.  
  374.         case 6:
  375.             config.bsdel=1;
  376.             CONFstate=0;
  377.             break;
  378.  
  379.         case 7:
  380.             setmacro( 0, (unsigned char *) s);
  381.             CONFstate=0;
  382.             break;
  383.         case 8:
  384.             setmacro( 1, (unsigned char *) s);
  385.             CONFstate=0;
  386.             break;
  387.         case 9:
  388.             setmacro( 2, (unsigned char *) s);
  389.             CONFstate=0;
  390.             break;
  391.         case 10:
  392.             setmacro( 3, (unsigned char *) s);
  393.             CONFstate=0;
  394.             break;
  395.         case 11:
  396.             setmacro( 4, (unsigned char *) s);
  397.             CONFstate=0;
  398.             break;
  399.         case 12:
  400.             setmacro( 5, (unsigned char *) s);
  401.             CONFstate=0;
  402.             break;
  403.         case 13:
  404.             setmacro( 6, (unsigned char *) s);
  405.             CONFstate=0;
  406.             break;
  407.         case 14:
  408.             setmacro( 7, (unsigned char *) s);
  409.             CONFstate=0;
  410.             break;
  411.         case 15:
  412.             setmacro( 8, (unsigned char *) s);
  413.             CONFstate=0;
  414.             break;
  415.         case 16:
  416.             setmacro( 9, (unsigned char *) s);
  417.             CONFstate=0;
  418.             break;
  419.         case 17:
  420.             if (affirmative(s))
  421.                 whichMenus=1;
  422.             else
  423.                 whichMenus=0;
  424.             switchMenus(whichMenus);
  425.             CONFstate=0;
  426.             break;
  427.         case 18:
  428.             if (strcmp(s,"backspace") )
  429.                 config.bsdel=1;
  430.             else
  431.                 config.bsdel=0;
  432.             CONFstate=0;
  433.             break;
  434.         case 19:
  435.         case 21:
  436.             if ( 1 != sscanf(s,"%d", &a) ) {
  437.                 config.width=80;
  438.                 }
  439.             config.width=a;
  440.             CONFstate=0;
  441.             break;
  442.         case 20:
  443.             if (affirmative(s))
  444.                 config.tekclear = 1;
  445.             else
  446.                 config.tekclear = 0;
  447.             CONFstate = 0;
  448.             break;
  449.         case 22:
  450.         case 23:
  451.         case 24:
  452.         case 25:
  453.             if ( 3 != sscanf(s, "{%u,%u,%u}", &a, &b, &c)) {    /* BYU LSC - "%d" changed to "%u" */
  454.                 putln("Bad Parms to rgb");
  455.                 return(2);
  456.                 }
  457.             config.red[  CONFstate-22]     =a;
  458.             config.green[CONFstate-22]    =b;
  459.             config.blue[ CONFstate-22]    =c;
  460.             CONFstate = 0;
  461.             break;
  462.         case 26:        /* Font Name */
  463. #ifndef MPW
  464.             c2pstr(s);                        /* BYU LSC */
  465. #endif MPW
  466.             GetFNum( s, &config.font);        /* BYU LSC */
  467.             CONFstate = 0;
  468.             break;
  469.         case 27:        /* Font Size */
  470.             if (1 == sscanf( s, "%d", &a))
  471.                 config.fsize=a;
  472.             CONFstate = 0;
  473.             break;
  474.         case 28:        /* number of lines to use for window's editable region */
  475.             if (1 == sscanf( s, "%d", &a))
  476.                 config.nlines=a;
  477.             CONFstate = 0;
  478.             break;
  479.         case 29:        /* keystop, XOFF key */
  480.             if (1 == sscanf( s, "%d", &a))
  481.                 config.TELstop=a;
  482.             CONFstate = 0;
  483.             break;
  484.         case 30:        /* keygo, XON key */
  485.             if (1 == sscanf( s, "%d", &a))
  486.                 config.TELgo=a;
  487.             CONFstate = 0;
  488.             break;
  489.         case 31:        /* keyip, kill key */
  490.             if (1 == sscanf( s, "%d", &a))
  491.                 config.TELip=a;
  492.             CONFstate = 0;
  493.             break;
  494.         case 32:        /* cr-map */
  495.             putln("got crmap");
  496.             if (1 == sscanf( s, "%d", &a))
  497.                 config.crmap=a;
  498.             CONFstate = 0;
  499.             break;
  500.         case 33:                    /* BYU 2.4.9 */
  501.             if (affirmative(s))        /* BYU 2.4.9 */
  502.                 config.lineAllow=1;    /* BYU 2.4.9 */
  503.             else                    /* BYU 2.4.9 */
  504.                 config.lineAllow=0;    /* BYU 2.4.9 */
  505.             CONFstate=0;            /* BYU 2.4.9 */
  506.             break;                    /* BYU 2.4.9 */
  507.         case 34:                    /* BYU 2.4.9 */
  508.             if (affirmative(s))        /* BYU 2.4.9 */
  509.                 config.eightbit=1;    /* BYU 2.4.9 */
  510.             else                    /* BYU 2.4.9 */
  511.                 config.eightbit=0;    /* BYU 2.4.9 */
  512.             CONFstate=0;            /* BYU 2.4.9 */
  513.             break;                    /* BYU 2.4.9 */
  514.         case 35:                    /* BYU */
  515.             config.ftpstate=1;        /* BYU */
  516.             CONFstate=0;            /* BYU */
  517.             break;                    /* BYU */
  518.         case 36:                    /* BYU serial */
  519.             config.connectionType=1;/* BYU serial */
  520.             CONFstate=0;            /* BYU serial */
  521.             break;                    /* BYU serial */
  522.         case 37:                                /* NCSA: get the real port # */
  523.             if (1 == sscanf( s, "%d", &a))        /* NCSA */
  524.                 config.port=a;                    /* NCSA */
  525.             CONFstate = 0;                        /* NCSA */
  526.             break;                                /* NCSA */
  527.         default:
  528.             putln("I'm so stateless....");
  529.             CONFstate=0;
  530.         }
  531.     return(0);
  532.   } /* confile */
  533.  
  534. /************************************************************************/
  535. /* Scontoken
  536. *  tokenize the strings which get passed to Sconfile.
  537. *  Handles quotes and uses separators:  <33, ;:=
  538. */ 
  539. int contoken
  540.   (
  541.     int c
  542.   )
  543.     {
  544.     int retval,scrn;
  545.  
  546.     if (c == EOF) {
  547.         Cspace[position++] = '\0';
  548.         putln("Eof handler called");
  549.         confile(Cspace);
  550.         if (CONFactive) {
  551.                 putln("attempting open");
  552.                 scrn=addport( &config );    /* Make our user window */
  553.                 if (scrn<0) {
  554.                     putln("ERROR IN OPENING!! ");
  555.                     return(42);
  556.                     }
  557.                 }
  558.         return(-1);
  559.     }
  560.     
  561.     if (!position && !inquote && Sissep(c))
  562.     /*if (!position && Sissep(c))    */    /* old_skip over junk before keyword */
  563.         return(0);
  564.  
  565.     if (inquote || !Sissep(c)) {
  566.  
  567.         if (position > 200) {
  568.             putln("Out of bounds error!");
  569.             return(1);
  570.         }
  571. /*
  572. *  check for quotes, a little mixed up here, could be reorganized
  573. */
  574.         if (c == '"' ) {
  575.             if (!inquote) {            /* beginning of quotes */
  576.                 inquote = 1;
  577.                 return(0);
  578.             }
  579.              Cspace[position++] =c;
  580.             return(0);
  581.         }
  582.         else 
  583.             {                        /* include in current string */
  584.             if (c != '\012' && c != '\015')        /* BYU 2.4.18 - changed \n to \015 and added \012 */
  585.                 {
  586.                 Cspace[position++] = c;
  587.                 return(0);
  588.                 }
  589.             }
  590.                 
  591.         }
  592.  
  593.     if (Cspace[position-1] == '"') position--;
  594.     Cspace[position++] = '\0';
  595.  
  596.     retval = confile(Cspace);            /* pass the token along */
  597.  
  598.     position = 0;
  599.     inquote = 0;
  600.     Cspace[0] = '\0';
  601.  
  602.     return(retval);
  603. }
  604.  
  605. /************************************************************************/
  606. /*  Sreadhosts
  607. *   read in the hosts file into our in-memory data structure.
  608. *   Handle everything by keyword, see docs for specifications about file.
  609. */
  610. int readconfig
  611.   (
  612.     char *Cfile
  613.   )
  614. {
  615.     int c,retval;
  616.  
  617.     Cspace = NewPtr(256);                /* BYU LSC - get room for gathering stuff */
  618.  
  619.     configdefault(&config);
  620.  
  621.     if (NULL == Cspace) {
  622. #ifndef MPW
  623.         OtherError((char *) "\PNo space for set to load",(char *) "\P ");    /* BYU LSC */
  624. #else
  625.         OtherError("No space for set to load"," ");
  626. #endif MPW
  627.         return(1);
  628.         }
  629.     
  630.     position = CONFstate = CONFactive = inquote = lineno = 0;   /* state vars */    
  631.  
  632.     if (NULL == (fp = fopen(Cfile,"r"))) {
  633.         putln("Couldn't open Configuration file:");
  634.         putln( Cfile);
  635.         return(1);
  636.     }
  637.  
  638.     retval = 0;
  639.     while (!retval) {
  640.         c = fgetc(fp);
  641.         if (c == '#' && !inquote) {
  642.             while (c != EOF && c != '\012' && c != '\015')        /* skip to EOL */    /* BYU 2.4.18 - changed \n to \015 and added \012*/
  643.                 c = fgetc(fp);
  644.         }
  645.         if (c == '\012' || c == '\015')            /* BYU 2.4.18 - changed \n to \015 and added \012 */
  646.             lineno++;
  647.         retval = contoken(c);
  648.     }
  649.  
  650.     fclose(fp);
  651.     DisposPtr((Ptr) Cspace);
  652.  
  653.     if (retval == EOF) {                /* EOF is normal end */
  654.         putln("EOF termination");
  655.         return(0);
  656.         }
  657.     else {
  658.         putln("NON-EOF termination");
  659.         return(retval);
  660.         }
  661. }
  662.  
  663. /*
  664.  * checkCONF - check if the user clicked on a configuration file
  665.  */
  666.  
  667. int checkCONF
  668.   (
  669.     void
  670.   )
  671. {
  672.     short i,mess,count,retcode=0;
  673.     AppFile theFile;
  674.  
  675.     CountAppFiles(&mess,&count);
  676.     if (mess==1) { putln("PRINTING...."); return(FALSE); }
  677.     if (count<1) { putln("No files (<1)"); return(FALSE); }
  678.     for(i=1;i<=count;i++) {
  679.         GetAppFiles(i, &theFile);
  680.         if (theFile.fType=='CONF') {
  681.             ClrAppFiles(i);
  682.             SetVol( 0L, theFile.vRefNum);
  683.             p2cstr( &theFile.fName);
  684.             readconfig((char *) &theFile.fName);    /* BYU LSC */
  685.             putln("file has been read");
  686.             retcode=1;
  687.             }
  688.         }
  689.     return(retcode);
  690. }
  691.  
  692.  
  693.